package com.example.data.repo;


import com.example.data.datasource.remote.IJsonPlaceHolderService;
import com.example.domain.entity.Post;
import com.example.domain.repo.JsonPlaceHolderRepo;
import com.example.domain.result.Result;

import java.util.List;

import javax.inject.Inject;

public class JsonPlaceHolderRepoImpl extends BaseRemoteRepo implements JsonPlaceHolderRepo {

    private IJsonPlaceHolderService jsonPlaceHolderService;

    @Inject
    JsonPlaceHolderRepoImpl(IJsonPlaceHolderService service) {
        this.jsonPlaceHolderService = service;
    }

    @Override
    public Result<List<Post>> getAllPost() {
        return safeRemoteCall(() -> jsonPlaceHolderService.getAllPosts());
    }

    @Override
    public Result<Post> getPostById(int id) {
        return safeRemoteCall(() -> jsonPlaceHolderService.getPostById(id));
    }
}
